/****************************************************************************/
/*                                                                          */
/* This file contains the interface functions                               */
/* you should use for the wet ex 1                                          */ 
/*                                                                          */ 
/****************************************************************************/

/****************************************************************************/
/*                                                                          */ 
/* File Name : library1.h                                                   */ 
/*                                                                          */ 
/****************************************************************************/

#ifndef _234218_WET1_
#define _234218_WET1_

#include "rational.h"

using namespace rational;

/* Return Values
 * ----------------------------------- */
typedef enum {
	SUCCESS = 0,
	FAILURE = -1,
	ALLOCATION_ERROR = -2,
	INVALID_INPUT = -3

} StatusType;


/* Required Interface for the Data Structure
 * -----------------------------------------*/


/* Description:   Initializes an empty hand.
 * Input:         K - Number of companies.
 * Output:        None.
 * Return Values: A pointer to a new instance of the data structure - as a void* pointer.
 */
void*       Init(int K);


/* Description:   Add a new employee to the system
 * Input:         DS - A pointer to the data structure.
 *				  id - the ID of the new employee
 *                company - The company at which the employee will work.
 *                salary - the salary of the employee
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, id<=0, company<0, company>K-1 or salary <= 0.
 *                FAILURE - If the employer already exists in the system or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  Hire(void* DS, int id, int company, Rational salary);


/* Description:   Fire an employee from its hiring company.
 * Input:         DS - A pointer to the data structure.
 *                id - the id of the employee.
 *                company - the company at which the employee works.
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, id<=0, company<0 or company>K-1.
 *                FAILURE - If the requested employee does not work at the requested company or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  Fire(void* DS, int id, int company);


/* Description:   Returns the company at which the requested employee works.
 * Input:         DS - A pointer to the data structure.
 * 				  id - the ID of the requested employee
 * Output:        company - the company at which the requested employee works.
 * Return Values: INVALID_INPUT - If DS==NULL or id <=0 or value==NULL.
 *                FAILURE - In case an employee with the requested id does not exists in the system or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  GetEmployer(void* DS, int id, int* company);


/* Description:   Returns the salary of an employee
 * Input:         DS - A pointer to the data structure.
 *                id - the ID of the requested employee
 * Output:        salary - the salary of the requested employee
 * Return Values: INVALID_INPUT - If DS==NULL, id<=0 or salary==NULL.
 *                FAILURE - In case no employee with the given id exists in the system or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  GetSalary(void* DS, int id, Rational* salary);


/* Description:   Returns the median salary at the requested company.
 * Input:         DS - A pointer to the data structure.
 * 				  company - the requested company.
 * Output:        salary - the median salary.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, company<0 or company>=K-1 or salary==NULL.
 *                FAILURE - In case there are no employees in the requested company or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  MedianSalary(void* DS, int company, Rational* salary);


/* Description:   Returns the highest salary of an employee in the requested company.
 * Input:		  DS - A pointer to the data structure.
 * 				  company - the requested company.
 * Output:        salary - the highest salary of an employee in the company.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, company<0, company>=K-1 or salary==NULL
 *                FAILURE - In case there are no employees in the requested company or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  HighestSalary(void* DS, int company, Rational* salary);


/* Description:   Update all salaries in the requested company by the given factor.
 * Input:         DS - A pointer to the data structure.
 * 				  company - the requested company
 * 				  update - the factor by which to increase all salaries in the requested company.
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, company<0, company>K-1 or update<=0.
 *                FAILURE - In case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  UpdateSalaries(void* DS, int company, Rational update);


/* Description:   Merges two companies. All employees of the sold company move to the buying company
 * 				  with the same salary as they had before, and the sold company ceases to exist.
 * Input:         DS - A pointer to the data structure.
 * 				  buyingCompany - the buying company.
 * 				  sellingCompany - the selling company.
 * Output:        None.
 * Return Values: ALLOCATION_ERROR - In case of an allocation error.
 *                INVALID_INPUT - If DS==NULL, buyingCompany<0, buyingCompany>K-1,
 *                sellingCompany<0, sellingCompany>K-1
 *                FAILURE - In case the buyingCompany was sold in the past to another company,
 *                			or sellingCompany was sold before already or in case of any other error.
 *                SUCCESS - Otherwise.
 */
StatusType  Merger(void* DS, int buyingCompany, int sellingCompany);


/* Description:   Quits and deletes the database.
 *                DS should be set to NULL.
 *                      
 * Input:         DS - A pointer to the data structure.
 * Output:        None.
 * Return Values: None.
 */
void        Quit(void** DS);

#endif    /*_234218_WET1_ */ 
